package com.daka.tools.rongYun;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 系统小助手
 * Created by chunyang on 2016/6/5.
 */
public class PushSystemMesssage
{

    //系统小助手
    public static final String SYSTEM_HELPER = "50493721-7bcb-4c36-8836-11cf4e331bb8";


    static PushSystemMesssage pushSystemMesssage = null;

    private PushSystemMesssage()
    {
    }

    /**
     *    类级的内部类，也就是静态的成员式内部类，该内部类的实例与外部类的实例
     *    没有绑定关系，而且只有被调用到时才会装载，从而实现了延迟加载。
     */
    private static class SingletonHolder{
        /**
         * 静态初始化器，由JVM来保证线程安全
         */
        private static PushSystemMesssage instance = new PushSystemMesssage();
    }

    public static PushSystemMesssage getInstance(){
        return SingletonHolder.instance;
    }

    /**
     * 社团开除成员
     * @param name
     * @param memberCode
     */
    public void expelGroupVolunteer(String name,String memberCode)
    {
        //推送消息至志愿者用户
        List<String> volunteers = new ArrayList<String>();
        volunteers.add(memberCode);
        PushMessageUtil.publishSystemMessage("您被"+name+"开除了", null, SYSTEM_HELPER, volunteers);
    }
    /**
     * 已成为注册志愿者
     * @param voluteerCode
     * @param memmberCode
     */
    public void agreenVolunteerApply(String voluteerCode,String memmberCode)
    {
        //推送消息至志愿者用户
        List<String> volunteers = new ArrayList<String>();
        volunteers.add(memmberCode);
        PushMessageUtil.publishSystemMessage("您已经成为注册志愿者，志愿者一号通编号为:"+voluteerCode,null,SYSTEM_HELPER ,volunteers);
    }
    /**
     * 拒绝成员加入社团的申请
     * @param name
     * @param memberCode
     */
    public void refuseGroupVolunteer(String name,String memberCode)
    {
        //推送消息至志愿者用户
        List<String> volunteers = new ArrayList<String>();
        volunteers.add(memberCode);
        PushMessageUtil.publishSystemMessage(name+"拒绝了您的申请。", null, SYSTEM_HELPER, volunteers);
    }
    /**
     * 冻结社团成员
     * @param name
     * @param memberCode
     */
    public void freezeGroupVolunteer(String name,String memberCode,String groupCode)
    {
        //推送消息至志愿者用户
        List<String> volunteers = new ArrayList<String>();
        volunteers.add(memberCode);
        PushMessageUtil.publishSystemMessage("您已被管理员冻结。", null, SYSTEM_HELPER, volunteers);
        PushMessageUtil.gagAdd(volunteers,groupCode,43200);
    }
    /**
     * 解冻社团成员
     * @param name
     * @param memberCode
     */
    public void freezeUnGroupVolunteer(String name,String memberCode,String groupCode)
    {
        //推送消息至志愿者用户
        List<String> volunteers = new ArrayList<String>();
        volunteers.add(memberCode);
        PushMessageUtil.publishSystemMessage("您已被管理员解冻。", null, SYSTEM_HELPER, volunteers);
        PushMessageUtil.gagRollback(volunteers,groupCode);
    }
    /**
     * 拒绝报名社团招募
     * @param name
     * @param memberCode
     */
    public void refuseGroupRecruit(String name,String memberCode)
    {
        //推送消息至志愿者用户
        List<String> volunteers = new ArrayList<String>();
        volunteers.add(memberCode);
        PushMessageUtil.publishSystemMessage(name + "招募拒绝了您的申请。", null, SYSTEM_HELPER, volunteers);
    }

    /**
     * 拒绝报名活动招募
     * @param name
     * @param memberCode
     */
    public void refuseActivityRecruit(String name,String memberCode)
    {
        //推送消息至志愿者用户
        List<String> volunteers = new ArrayList<String>();
        volunteers.add(memberCode);
        PushMessageUtil.publishSystemMessage(name+"招募拒绝了您的申请。" , null, SYSTEM_HELPER, volunteers);
    }
//    /**
//     * 取消活动
//     * @param activityId
//     * @param activityName
//     * @param activityMonitorName
//     */
//     public void delActivity(BaseDAO baseDAO,long activityId,String activityName,String activityMonitorName)
//     {
//         List<String> volunteers = new ArrayList<String>();
//         //查询活动的所有打卡记录
//         String sql = "SELECT MEMBER_CODE FROM U_VOLUNTEER AS A INNER JOIN (SELECT VOLUNTEER_ID FROM U_ACTIVITY_APPLY WHERE ACTIVITY_ID = " + activityId + " AND DEL_STATUS = "  + DKQConstant.DEL_NO + ") AS B ON B.VOLUNTEER_ID = A.ID";
//         List<Map<String,String>> list = baseDAO.queryNativeSql(sql);
//         if(null != list && list.size()>0)
//         {
//             for(Map<String,String> map:list)
//                 volunteers.add(map.get("MEMBER_CODE"));
//         }
//         //推送消息至志愿者用户
//         PushMessageUtil.publishSystemMessage(activityMonitorName+"取消了"+activityName+"活动", null, SYSTEM_HELPER, volunteers);
//     }
}
